<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{$meta}
<link type="text/css" rel="stylesheet" href="{$css_path}/global.css" />
<link type="text/css" rel="stylesheet" href="{$css_path}/style.css" />
</head><body>
<!--头部--> 
{include file="top.html"}
{include file="header.html"} 
<!--登录-->
<div id="main">
  <div id="q2a_ask_left"> {include file="message.html"}
   <form id='form_trade' action="{$site_url}trade/add" method="post" enctype="MULTIPART/FORM-DATA">
        <input type="hidden" value="{$token}" name="token">
        <table border='0' width="100%">
          <tr class='q_title'>
            <td  width="14%">标 题：</td>
            <td ><input  id='name' class='text big' type='text' name='name' size="60" /></td>
          </tr>
          <tr class='q_type'>
            <td >任务：</td>
            <td ><select name="post_type">
                <option value="supply">任务</option>
                <option value="demand">需求</option>
              </select></td>
          </tr>
          <tr class='q_title'>
            <td >手机：</td>
            <td ><input  id='mobile_phone' class='text' type='text' name='mobile_phone' size="20" /></td>
          </tr>
          <tr class='q_title'>
            <td >固定电话：</td>
            <td ><input  id='telphone' class='text' type='text' name='telphone' size="20" /></td>
          </tr>
          <tr>
            <td >有效时间：</td>
            <td ><input type="text" name="limit_time"  value="" class="text small Wdate"  onClick="WdatePicker({minDate:'%y-%M-%d',doubleCalendar:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})">
              <p>不填为永不过期</p></td>
          </tr>
          <tr>
            <td >分 类：</td>
            <td ><select name="category_id" id="category_id">
                <option value="">==选择分类==</option>
               {$category_option}
              </select></td>
          </tr>
          
          
          <tr id='tr_area'>
                <td>地区所在：</td>
                <td><select name="province_id" id="province_id">
                    <option value=''>--选择省份--</option>
                     {foreach from=$province item=p}
                    <option value='{$p.id}' {if $data.province == $p.id}selected='selected'{/if}>{$p.name}</option>
                    {/foreach}                         
                  </select>
                  <span id="sub_id">
                  <select name='city_id' id="city_id">
                    
                         <option value=''>--选择城市--</option>   
                                                        
                  </select>
                  </span>
                  详细地址：<input type="text" name="address" class='text'>
                  </td>
              </tr>
          <tr>
            <td>金额：</td>
            <td><input  id='account' class='text' type='text' name='account' size="10" />
              <p>0：免费;不填为面议</p></td>
          </tr>
          <tr>
            <td >描述</td>
            <td>
              <textarea tabindex='7' name="content" id="content" style="widtd:580px;height:200px;"></textarea></td>
          </tr>
          <tr>
            <td></td>
            <td colspan='2'></td>
          </tr>
          <tr>
            <td widtd="80">上传附件</td>
            <td><input type="file" name="attachment" id="attachment" class="file"/></td>
          </tr>
          
          <tr>
            <td>验证码：</td>
            <td><input type='text' id='captcha' name='captcha' size='6' class='text'/>
             </td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>    <div>{$captcha}<span><a href="javascript:reloadcode();">换另外一个图</a></span></div></td>
          </tr>
          <tr>
            <td colspan="3" align="center"> <input type="submit"  class="btnzc" value="发&nbsp;&nbsp;布"/></td>
          </tr>
        </table>
      </form>
    <div class="clear"></div>
  </div>
  <div id="q2a_ask_right">
    <div id="question_tip">
      <h2>发布规则规则</h2>
      <ol>
        <li>清晰说明问题</li>
        <li>关键词非常重要,方便通过标签找到问题</li>
        <li>问题的内容尽量的描述清晰</li>
      </ol>
    </div>
    <img src="{$images_patd}/right_img.png"> </div>
  <div class="clear"></div>
</div>
<script type="text/javascript" src="{$js_path}/message.js"></script> 
<script type="text/javascript" src="{$js_path}/jquery.validate.js"></script> 
<script type="text/javascript" src="{$js_path}/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="{$js_path}/kindeditor/kindeditor-min.js"></script>
<script>
  var editor;
  KindEditor.ready(function(K) {
	  editor = K.create('#content', {
		  resizeType : 0,
		  allowPreviewEmoticons : false,
		  filterMode : false,
		  allowImageUpload : false,
		  items : [
			  'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			  'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			  'insertunorderedlist', '|', 'emoticons',  'link']
	  });
  });
</script>
<script>
   function reloadcode(){
        document.getElementById('captcha_change').src = '{$site_url}captcha/default?r='+Math.random(); 
    } 
$(function(){
	 $("#form_trade").validate({
		   errorElement:"p",
		  rules: {
			  name: {
				  required: true,
				  maxlengtd:30
			  },
			  content:{
				  required: true,
				  minlengtd: 20
			  },
			   mobile_phone:{
				  required: true,
				  number: true
			  },
			  account:{
				  digits: true
			  },
			  category_id:'required',
			  captcha:'required',
			  address:'required'
		  },
		  messages: {
			  name: {
				  required: "标题不能为空!",
				  maxlengtd: "标题必须小于30位!"
			  },
			  content:{
				  required:'内容不能为空',
				  minlengtd:'内容必须大于20位'
			  },
			  mobile_phone:{
				  required: '内容不能为空',
				  number: '必须为数字'
			  },
			  category_id:'分类必填',
			  captcha:'验证码必填',
			  address:'所在地区不能为空'
		  }
	  });
	  
	    //修改某一个省的城市列表
	$('#province_id').change(function(){
		$.ajax({
			url:"{$site_url}ajax/sub_area",
			type:'post',
			data:'id='+$(this).val(),
			dataType:'json',
			success:function(data){
				$('#sub_id').html('');
				if(data != ''){
					var html = "<select name='city_id'>";
					$.each(data,function(i,n){
						 html +="<option value='"+n.id+"'>"+n.name+"</option>";
					});
					html +="</select>";
					$('#sub_id').html(html);
				}
			}
		});
	});
	
	
	$('#category_id').change(function(){
		$.ajax({
			url:"{$site_url}trade/ajax/category_template",
			type:'post',
			data:'id='+$(this).val(),
			success:function(data){
			  if(data != 1){
				  editor.html(data);
			  }
			}
		});
	});
})
</script> 
{include file="footer.html"}
</body>
</html>
